<include file="Public/header"/>
<div class="row">
<div class="col s12 m8">
        <div class="f-events-and-clubs-detail-bloc">
            <div class="card f-events-and-clubs-detail">
                <div class="card-content f-events-and-clubs-detail-content">
                    <switch name="activityInfo['type']">
                        <case value='1'>
                            <p class="card-title f-clubs-title">
                                <i class="center">
                                    <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid"
                                         viewBox="0 0 23 18">
                                        <path d="M6 6.7l0.8 0.1c0-0.1 0.3-2.2-1-3.5l0.1-0.3c1.1 0.2 4 0.6 6.5-1.8 2.5 2.4 5.4 2 6.5 1.8l0.1 0.3c-1.3 1.3-1 3.4-1 3.5l0.8-0.1c0 0-0.3-2 0.9-3l0.2-0.2 -0.4-1.6 -0.4 0.1c0 0-3.6 1.2-6.4-1.8L12.4 0l-0.3 0.3C9.3 3.2 5.8 2.1 5.7 2.1L5.2 1.9 4.8 3.5 5 3.7C6.2 4.7 6 6.6 6 6.7zM24.8 7.9l-1.9-1.5L23.4 3.9l-4.1 1.8 0.4 1.7 -2.5 0.7c-0.5-2.3-2.5-4-4.9-4 -2.4 0-4.4 1.7-4.9 3.9L5 7.4l0.4-1.7L1.4 3.9l0.6 2.5L0 7.9l2.5 1.3 -0.1 1.4 5.9 1.5c0.9 1.3 2.4 2.1 4.1 2.1 1.7 0 3.2-0.8 4.1-2.1l6-1.5 -0.1-1.4L24.8 7.9zM15.6 15l-0.4 0.1c-0.9 0.3-2.1 0.8-2.9 1.9 -0.7-1.1-2-1.5-2.9-1.9L9.1 15c-0.7-0.3-2.2-1.3-2.4-2.8L5.9 12.3c0.3 1.9 2 3.1 2.9 3.4l0.4 0.2c1 0.4 2.3 0.9 2.8 2.1l0.4 1.1 0.4-1.1c0.4-1.2 1.8-1.8 2.8-2.1l0.4-0.1c0.9-0.4 2.7-1.6 2.9-3.4l-0.8-0.1C17.8 13.7 16.3 14.7 15.6 15z"
                                              fill="#737373"/>
                                    </svg>
                                </i>
                                <eq name="Think.session.lang" value="1">
                                    Clubs
                                <else/>
                                    俱乐部
                                </eq>  
                            </p>                        
                        </case>
                        <case value='2'>
                            <p class="card-title f-clubs-title">
                                <i class="center">
                                    <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid"
                                                             viewBox="0 0 18 18">
                                            <rect x="0" y="0" fill="#FFFFFF" width="16" height="16"/>
                                            <path fill="#787878" d="M8.1,0C3.6,0,0,3.6,0,8.1c0,4.5,3.6,8.1,8.1,8.1s8.1-3.6,8.1-8.1C16.2,3.6,12.6,0,8.1,0z M7.7,3.4
                                            c1.3,0,2.4,1.1,2.4,2.4c0,1.3-1.1,2.4-2.4,2.4c-1.3,0-2.4-1.1-2.4-2.4C5.3,4.5,6.4,3.4,7.7,3.4z M8.1,15.2c-2.1,0-4.1-1-5.4-2.5
                                            C3.4,10.6,5.4,9,7.7,9c2.6,0,4.7,1.9,5.1,4.4C11.6,14.5,9.9,15.2,8.1,15.2z"/>
                                    </svg>
                                </i>
                                    <eq name="Think.session.lang" value="1">
                                        Departments
                                    <else/>
                                        部门
                                    </eq>
                            </p>   
                        </case>
                        <case value='3'>
                            <p class="card-title f-events-title-bloc">
                                <i class="center">
                                    <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid" viewBox="0 0 20 10">
                                        <path d="M16.6 0c-0.9 0-1.6 0.7-1.6 1.6 0 0.3 0.1 0.5 0.2 0.7L11.9 5.7c-0.2-0.1-0.5-0.2-0.7-0.2 -0.2 0-0.3 0-0.5 0.1L8.4 2.5c0.2-0.3 0.3-0.6 0.3-0.9C8.7 0.7 8 0 7.1 0 6.2 0 5.5 0.7 5.5 1.6c0 0.3 0.1 0.5 0.2 0.7L2.3 5.7c-0.2-0.1-0.5-0.2-0.7-0.2C0.7 5.5 0 6.2 0 7.1c0 0.9 0.7 1.6 1.6 1.6s1.6-0.7 1.6-1.6c0-0.3-0.1-0.5-0.2-0.7l3.3-3.3c0.2 0.1 0.5 0.2 0.7 0.2 0.2 0 0.3 0 0.5-0.1l2.2 3c-0.2 0.3-0.3 0.6-0.3 0.9 0 0.9 0.7 1.6 1.6 1.6s1.6-0.7 1.6-1.6c0-0.3-0.1-0.5-0.2-0.7l3.3-3.3c0.2 0.1 0.5 0.2 0.7 0.2 0.9 0 1.6-0.7 1.6-1.6C18.2 0.7 17.5 0 16.6 0z" fill="#737373"></path>
                                    </svg>
                                </i>
                                    <eq name="Think.session.lang" value="1">
                                        Events
                                    <else/>
                                        事件
                                    </eq>
                            </p>
                        </case>                
                    </switch>

                    <div class="f-clubs-detail-post-author">
                        Posted on
                        <time id='date' style='color:#039BE5'><{$activityInfo.add_time|substr=0,10}></time>
                        by&nbsp;<span><a href="<{:U('User/info',array('id'=>code($activityInfo['assign_user_id'],1)))}>"><{$activityInfo.assign_user_id|getUsername}></a></span>
                        <div class="right f-clubs-detail-manipulate">
                            <eq name="Think.session.home.id" value="$activityInfo.assign_user_id">

                                <a class="modal-trigger center" href="#modal1" id='edit'><i class="material-icons f-font-22" >mode_edit</i></a>
                                <a 
                                    <eq name="Think.session.lang" value="1">
                                        onclick="if (confirm('Are you sure you want to delete this activity?')) return true; else return false;" 
                                    <else/>
                                        onclick="if (confirm('确实要删除此活动吗?')) return true; else return false;" 
                                    </eq>
                                    class="center" 
                                   href="<{:U('Club/delActivity',array('id'=>code($activityInfo['id'],1),'name'=>code($_SESSION['home']['name'],1),'group_id'=>code($activityInfo['group_id'],1),'type'=>code($activityInfo['type'],1)))}>">
                                    <i class="material-icons f-font-26">close</i>
                                </a>
                            </eq>
                        </div>
                    </div>
                    <input type="hidden" name='id' value="<{$activityInfo['id']}>"/>                        
                    <input type='hidden' name='valid' value="<{$activityInfo.validity}>"/>
                    <input type="hidden" name="type_s" value="<{$activityInfo.type}>" />
                    <script>
                        $(function(){
                            $("#edit").click(function(){
                                var valid=$("input[name='valid']").val();
                                var type_s  =$("input[name='type_s']").val();
                                var theme   =$("#theme").html();
                                var content =$("#content").html(); 
                                $("#theme_time").show();
                                $("#title").val(theme);
                                $("#datetime").val(valid);
                                $("#textarea1").val(content);
                                $("input[name='type']").val(type_s);
                                $("#re").html("Edit");
                            });
                        });
                    </script>
                    <eq name="Think.session.lang" value="1">
                        <h3 id='theme'><{$activityInfo.en_theme}></h3>
                        <p class="f-clubs-detail-address f-font-14">Add:<span>ShenZheng NanShanQu ShenNanDaDao</span></p>
                        <p id='content'><{$activityInfo.en_content}></p>
                        <p>
                            Join us in this club, and we move together.
                        </p>
                    <else/>
                        <h3 id='theme'><{$activityInfo.theme}></h3>
                        <p class="f-clubs-detail-address f-font-14">地址：<span>深圳市南山区深南大道</span></p>
                        <p id='content'><{$activityInfo.content}></p>
                        <p>
                            加入我们，让我们一起行动！
                        </p>
                    </eq>
                    
                    
                    <div class="row f-clubs-detail-bottom">
                        <div class="col m8 s6 f-clubs-detail-participant-and-comment left-align">
                            <a class="modal-trigger" href="#modal1" id='comment'>
                                <eq name="Think.session.lang" value="1">
                                    COMMENT
                                <else/>
                                    评论
                                </eq>                                
                            </a>
                        </div>
                        <p class="col m4 s6 f-btn right-align">
                            <button class="btn waves-effect waves-light f-btn-blue c-font-bold f-btn-small" type="submit"
                                    name="action" id='join'>
                                <eq name="Think.session.lang" value="1">
                                    <switch name='status' >
                                        <case value='3'>Already joined</case>
                                        <case value='2'>Audit</case>
                                        <default/>Join
                                    </switch>
                                <else/>
                                    <switch name='status' >
                                        <case value='3'>已加入</case>
                                        <case value='2'>审核中</case>
                                        <default/>加入
                                    </switch>
                                </eq>   
                            </button>
                        </p>
                    </div>
                    <div class="f-events-and-clubs-detail-participant">
                        <ul class="collection">
                            <foreach name="users" item="users">
                                <li class="collection-item avatar">
                                    <a  href="<{:U('User/info',array('id'=>code($users['id'],1)))}>" title="<{$users.name}>">
                                        <img src="<{$Think.const.PUBLIC_URL}><{$users.small_photo}>" alt="" class="circle"></a>
                                </li>
                            </foreach>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <!--
        <div id="modal3" class="modal f-participant-detail-bloc">
            <ul class="modal-content collection f-participant-detail-collection">
                <li class="collection-item avatar">
                    <img src="assets/images/Fantem-intranet-club-badminton.jpg" alt="" class="circle">
                    <span class="title">Lucy Tniy</span>
                    <p>Engineeing B</p>
                    <p>Sony first opened — and quickly closed — preorders for its PlayStation VR headset back in March</p>
                    <p class="card-action"><a class="modal-trigger" href="#modal1">Replay</a><a href="#!" class="modal-close">Add</a></p>
                </li>
            </ul>
        </div>
        -->
        
        <script>
            $.ajaxSetup({
                async: false
            });
            $(function(){
                $("#comment").click(function(){
                    $("#theme_time").hide();                    
                    $("#textareal").val('');
                    $("input[name='type']").val(5);
                    $("#re").html("Reply");
                });
                $("#join").click(function(){
                    //alert($.trim($("#join").html().substring(0,55)));
                    var type_s      =$("input[name='type_s']").val();
                    var active_id   =$("input[name='id']").val();
                    if($.trim($("#join").html().substring(0,55))=="加入" ||$.trim($("#join").html().substring(0,55))=='Join'){
                        $.post("__CONTROLLER__/ajaxActive",{type:type_s,id:active_id},function(data){
                           if(data==1){
                               if("<?php echo $_SESSION['lang'];?>"=='1'){
                                    alert("Application submission, waiting for review");
                                    $("#join").html("Audit");
                                }else{                                    
                                    alert("申请提交，等待审核");
                                    $("#join").html("审核中");
                                }
                            }else if(data==2){
                                if("<?php echo $_SESSION['lang'];?>"=='1'){
                                    alert("Department activities, non departmental staff can not participate.");
                                }else{
                                    alert("部门活动，非部门员工不能参与");
                                }
                            }else if(data==3){
                                if("<?php echo $_SESSION['lang'];?>"=='1'){
                                    alert("Non club members, please apply to join the club.");
                                }else{
                                    alert("非俱乐部成员，请先申请加入俱乐部");
                                }
                            }
                        });
                    }else if($.trim($("#join").html().substring(0,55))=="已加入" ||$.trim($("#join").html().substring(0,55))=="Already joined"){
                        $.post("__CONTROLLER__/ajaxOut",{id:active_id},function(data){
                            if(data==1){
                                if("<?php echo $_SESSION['lang'];?>"=='1'){
                                    alert("Application submission, waiting for review");
                                    $("#join").html("Audit");
                                }else{                                    
                                    alert("申请提交，等待审核");
                                    $("#join").html("审核中");
                                }
                            }
                        });
                    }
                });
            }); 
        </script>
        <!-- f-replay-bloc -->
        <div class="modal f-modal-bloc" id="modal1">
            <div class="modal-content f-modal">
                <h4 id='re'>
                    <eq name="Think.session.lang" value="1">
                        Edit
                    <else/>
                        编辑
                    </eq>
                </h4>
                <form method="post" action="<{:U('Club/edit_reply')}>" id='active'>
                    <input type="hidden" name="type" value="" />            
                    <input type="hidden" name='active_id' value="<{$activityInfo.id}>"/>
                    <input type="hidden" name="accept_user_id" value=""/>
                    <input type="hidden" name="reply_id" value=""/>
                    <div class="row"  id="theme_time">
                        <div class="input-field col m6 s12">
                            <input id="title" type="text" class="validate" name='theme' value=''>
                            <label for="title">
                                <eq name="Think.session.lang" value="1">
                                    Title
                                <else/>
                                    主题
                                </eq>
                            </label>
                        </div>  
                        <div class="input-field col s12 m6">
                            <input id="datetime" type="text" class="validate" name="validity" placeholder='2016-07-26'>
                            <label for="datetime">
                                <eq name="Think.session.lang" value="1">
                                    Time
                                <else/>
                                    时间
                                </eq>
                            </label>
                        </div>
                    </div>
                    <div class="row">
                        <div class="input-field col s12">
                            <textarea id="textarea1" class="materialize-textarea" length="120" name='content'></textarea>
                            <label for="textarea1" class="">
                                <eq name="Think.session.lang" value="1">
                                    Textarea
                                <else/>
                                    内容
                                </eq>
                            </label>
                            <span class="character-counter" style="float: right; font-size: 12px; height: 1px;"></span>
                        </div>
                    </div>
                </form>
                <div class="modal-footer">
                    <p class="f-btn center">
                        <button class="btn waves-effect waves-light f-btn-blue c-font-bold f-btn-small modal-close"  name="action" id="sub">
                            <eq name="Think.session.lang" value="1">
                                SUBMIT
                            <else/>
                                提交
                            </eq>
                        </button>
                        <button class="btn waves-effect waves-light f-btn-blue c-font-bold f-btn-small modal-close"  name="action">
                            <eq name="Think.session.lang" value="1">
                                CANCEL
                            <else/>
                                取消
                            </eq>
                        </button>
                    </p>
                </div>
            </div>
        </div>
        <script>
            $(function(){
                $("#sub").click(function(){
                    var name    =$("input[name='title']").val();
                    var validity= Date.parse(new Date($("input[name='validity']").val()));
                    if(!$("#theme_time").is(":hidden")){
                        if(name==''){
                            if("<?php echo $_SESSION['lang'];?>"=='1'){
                                alert("Activity theme can not be empty");
                                return false;
                            }else{
                                alert("活动主题不能为空");
                                return false;
                            }
                        }
                        if(validity==''){
                            if("<?php echo $_SESSION['lang'];?>"=='1'){
                                alert("Activity time can not be empty");
                                return false;
                            }else{
                                alert('活动时间不能为空');
                                return false;
                            }
                        }else if(!validity){
                            if("<?php echo $_SESSION['lang'];?>"=='1'){
                                alert("Active time format is not correct");
                                return false;
                            }else{
                                alert("活动时间格式不正确");
                                return false;
                            }
                        }     
                    }
                    $("#active").submit();
                });
            });                
        </script>   
        <neq name="replyThemeList[0]['id']" value="">
            <div class="card f-comment-bloc">            
                <div class="card-content">
                    <ul class="collection f-comment-collection">
                        <foreach name="replyThemeList" item="rTList">
                            <li class="collection-item avatar">
                                <img src="<{$Think.const.PUBLIC_URL}><{$rTList.assign_user_id|getPhoto}>" alt="" class="circle">
                                <p class="collection-item-content">
                                    <eq name="Think.session.lang" value="1">
                                        <{$rTList.en_content}>
                                    <else/>
                                        <{$rTList.content}>
                                    </eq>
                                </p>
                                <p class="time"><span><{$rTList.assign_user_id|getUsername}> posted on</span><{$rTList.add_time}></p>
                                <p class="card-action">
                                    <neq name="_SESSION['home']['id']" value="$rTList.assign_user_id"><a class="modal-trigger" href="#modal1" onclick="clickData(this)" id="<{$rCList.assign_user_id}>" reply_id="<{$rCList.id}>">
                                            <eq name="Think.session.lang" value="1">
                                                Replay
                                            <else/>
                                                回复
                                            </eq>
                                        </a></neq>
                                    <eq name="_SESSION['home']['id']" value="$rTList.assign_user_id"><a 
                                            <eq name="Think.session.lang" value="1">
                                                onclick="if (confirm('Are you sure you want to delete this comment?')) return true; else return false;"
                                            <else/>
                                                onclick="if (confirm('确定要删除这条评论吗?')) return true; else return false;"
                                            </eq>
                                            href="<{:U('Club/delReply',array('id'=>code($rTList['id'],1)))}>">
                                            <eq name="Think.session.lang" value="1">
                                                delete
                                            <else/>
                                                删除
                                            </eq>
                                        </a></eq>
                                </p>

                                <ul class="collection f-comment-collection">
                                    <foreach name="replyConList" item="rCList">
                                        <if condition="$rCList['sign'] eq $rTList['sign']+a">
                                            <li class="collection-item avatar">
                                                <img src="<{$Think.const.PUBLIC_URL}><{$rCList.assign_user_id|getPhoto}>" alt="" class="circle">
                                                <p class="collection-item-content">
                                                    <eq name="Think.session.lang" value="1">
                                                    <{$rCList.en_content}>
                                                <else/>
                                                    <{$rCList.content}>
                                                </eq>
                                                </p>
                                                <p class="time"><span><{$rCList.assign_user_id|getUsername}> posted on</span><{$rCList.add_time}></p>
                                                <p class="card-action">
                                                    <neq name="_SESSION['home']['id']" value="$rCList.assign_user_id"><a class="modal-trigger" href="#modal1" onclick="clickData(this)" id="<{$rCList.assign_user_id}>" reply_id="<{$rCList.id}>">Replay</a></neq>
                                                    <eq name="_SESSION['home']['id']" value="$rCList.assign_user_id">
                                                        <a 
                                                            <eq name="Think.session.lang" value="1">
                                                                onclick="if (confirm('Are you sure you want to delete this reply?')) return true; else return false;"
                                                            <else/>
                                                                onclick="if (confirm('确定要删除这条回复吗?')) return true; else return false;"
                                                            </eq>
                                                            href="<{:U('Club/delReply',array('id'=>code($rCList['id'],1)))}>">
                                                            <eq name="Think.session.lang" value="1">
                                                                delete
                                                            <else/>
                                                                删除
                                                            </eq>
                                                    </a></eq>
                                                </p>
                                            </li>
                                        </if>
                                    </foreach>
                                </ul>
                            </li>
                        </foreach>
                    </ul>
                </div>
            </div>
        </neq>
    </div>
<!--中间end-->
<include file='Public/foot'/>

 <script>
       function clickData(obj){
            var id      =$(obj).attr("id");
            var reply_id=$(obj).attr("reply_id");
            $("#theme_time").hide(); 
            $("#textarea1").val('');
            $("input[name='accept_user_id']").val(id);
            $("input[name='reply_id']").val(reply_id);
            $("input[name='type']").val(5);
            $("#re").html("Reply");
        }
    </script>
